package Easy中序遍历;

import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.List;

public class Solution {
    List<Integer> list = new ArrayList<>();
    public List<Integer> inorderTraversal(TreeNode root) {
        if (root != null) {
            inorderTraversal(root.left);
            list.add(root.val);
            inorderTraversal(root.right);
        }
        return list;
    }

    @Test
    public void test(){
        TreeNode tree = new TreeNode(1,null,new TreeNode(2,new TreeNode(3),null));
        List<Integer> l = inorderTraversal(tree);
        for (Integer i:l
        ) {
            System.out.println(i);
        }
    }
}
